package day019.homework.p5;

import day019.ioStream.FileInputStreamDemo7;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class InputStreamTest {
    public static void main(String[] args) throws IOException {
        String filePath = "D:/file01.txt";
        File file = new File(filePath);
        file.createNewFile();
        read1(file);
        read2(file);
    }

    private static void read1(File file) throws IOException {
        FileInputStream fis = new FileInputStream(file);
        int b;
        while ((b = fis.read()) != -1) {
            System.out.print(b + " ");
        }
    }

    private static void read2(File file) throws IOException {
        FileInputStream fis = new FileInputStream(file);
        byte[] bys = new byte[1024];
        int len;
        while ((len = fis.read(bys)) != -1) {
            System.out.print(new String(bys, 0, len) + " ");
        }
    }
}
